/*
 * OrderParameter.cpp
 *
 *  Created on: Aug 2, 2012
 *      Author: koschke
 */

#include "OrderParameter.h"
#include <votca/csg/csgapplication.h>
#include <votca/csg/beadlist.h>
#include <votca/csg/nblistgrid.h>

OrderParameter::OrderParameter(Topology * _top, BeadList * _beadList) {
	top = _top;
	beadList = _beadList;
	nbListGrid = new NBListGrid;
	lqVec.resize(top->MoleculeCount());
}

OrderParameter::~OrderParameter() {
	delete nbListGrid;
	//TODO do I have to delete the neighborMatrix?
	//TODO do I have to delete lqVec?
}

/* naive function to create a matrix [][] with neighbors */
void OrderParameter::createNeighborMatrix(NBListGrid* _nbListGrid,
		Topology* _top, vector<vector<int> >* _neighborList) {
	NBList::iterator i;

	int firstId, secondId;
	for (int j = 0; j < _top->MoleculeCount(); j++) {
		_neighborList->push_back(vector<int>());
	}
	for (i = _nbListGrid->begin(); i != _nbListGrid->end(); ++i) {
		firstId = (*i)->first->getId();
		secondId = (*i)->second->getId();
    /* save neighbor pair */
		(*_neighborList)[firstId].push_back(secondId);
		(*_neighborList)[secondId].push_back(firstId);
	}
}

